const Router = require("koa-router");
// 不同模块都有前缀
const {verifyToken} = require("../middlewares/auth.middle")

const router = new Router({ prefix: "/bl-cate" });
const {
  queryList,
  modifyControl,
  addControl,
  queryInfoControl,
  deleteControl,
  deleteSelectControl,
} = require("../controller/categoryController");
const {
  verifyModifyParam,
  verifyAddParam,
  verifyQueryParams,
  verifyDeleteId,
  verifyDeleteIds,
} = require("../middlewares/cate.middle");

router.post("/queryAll",verifyQueryParams,queryList);
/**
 * @swagger
 * /bl-cate/queryAll:
 *   post:
 *     tags:
 *       - Categories
 *     summary: 查询所有分类
 *     parameters:
 *       - in: body
 *         name: category
 *         description: 携带参数
 *         schema:
 *           type: object
 *           properties:
 *             typeName:
 *               type: string
 *     responses:
 *       200:
 *         description: Success
 */


/**
 * @swagger
 * /bl-cate/modify:
 *  post:
 *     tags:
 *      - Categories
 *     summary: 修改分类
 */
router.post("/modify", verifyToken,verifyModifyParam, modifyControl);
/**
 * @swagger
 * /bl-cate/add:
 *    post:
 *      tags:
 *         - Categories
 *      summary: 添加分类
 */
router.post("/add", verifyToken,verifyAddParam, addControl);
/**
 * @swagger
 * /bl-cate/queryCateInfo:
 *    get:
 *      tags:
 *         - Categories
 *      summary: 查询分类详情
 */
router.get("/queryCateInfo", verifyToken,queryInfoControl);
/**
 * @swagger
 * /bl-cate/delete:
 *  post:
 *    tags:
 *      - Categories
 *    summary: 按id删除分类
 */
router.post("/delete", verifyToken,verifyDeleteId, deleteControl);
router.post("/deleteSelect", verifyToken,verifyDeleteIds, deleteSelectControl);
module.exports = router;
